<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Request;

use SiteService;

class FrontMiddleware
{
    public function handle(Request $request, Closure $next)
    {
        if ($this->initSite() === false) {
            abort(404);
        }

        return $next($request);
    }

    /**
     * 初始化站点
     * @return boolean
     */
    protected function initSite(): bool
    {
        return SiteService::getSiteByDomain() ? true : false;
    }
}
